getMonthBreakdown <- function(compProdKey, start, end, incremeant, fileName) {
  x <- incremeant
  for(i in seq(start,end,by=x)) {
    urlInfo <- getResumeCount(compProdKey,str_c(toString(i),'-',toString(i+x)))
    if(urlInfo$count > 1000 && x != 1) {
      getMonthBreakdown(compProdKey,i,i+x,ceiling(x/2),fileName)
    } else {
      write.table(col.names=FALSE, quote=FALSE, urlInfo,file=fileName,append=TRUE, sep=',' ,eol='\r\n', row.names=FALSE)
    }
  }
}

getResumeCount <- function(compProdKey, yearsOfExperience) {
  urlInfo <- data.frame(link=NULL,count=NULL)
  
  url <- 'http://www.indeed.com/resumes'
  queryStr <- str_c('?q=',compProdKey,'&rb=yoe:', yearsOfExperience)
  finalUrl <- str_c(url, queryStr)
  countResult <- htmlParse(finalUrl)
  countXML <- getNodeSet(countResult,'//div[@id=\'result_count\']')
  count <- as.numeric(str_replace(str_replace_all(xmlToDataFrame(countXML)$text,'[a-zA-Z]',''),',',''))
  numberOfResumes <- count[[1]]
  urlInfo <- rbind(urlInfo,data.frame(link=finalUrl,count=numberOfResumes))
  return (urlInfo)
}
